package com.cuit.spring.exception;

import com.cuit.spring.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 全局异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandle {


    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result hanlde(ServiceException serviceException){
        return Result.error(serviceException.getCode(),serviceException.getMessage());
    }
}
